package com.fengye.netty.bootstrap;

import io.netty.channel.ChannelInitializer;
import io.netty.channel.ChannelPipeline;
import io.netty.channel.socket.SocketChannel;
import io.netty.handler.codec.http.HttpServerCodec;

public class TestServerInitializr extends ChannelInitializer<SocketChannel> {
    
    @Override
    protected void initChannel(final SocketChannel ch) throws Exception {
        final ChannelPipeline pipeline = ch.pipeline();
        
        //不要是单例的,每次请求都 new 出来一个新对象
        pipeline.addLast("httpServerCodec", new HttpServerCodec());
        
        //自定义的处理器
        pipeline.addLast("testServerHandler", new TestServerHandler());
    }
}
